import Vue from 'vue';
import Vuex from 'vuex';
import createPersistedState from 'vuex-persistedstate'
Vue.use(Vuex);
const config = {
    plugins: [createPersistedState()],
    state: {
        isLogin: false,
        username: '',
        token: '',
        // token: 'qcg6ik126bxohutpk9ij4ne7g'
        houseId: '',
        startDate: '',
        endDate: '',
        totalMoney: ""

    },
    getters: {
        isLogin: state => state.isLogin,
        token: state => state.token,
        username: state => state.username,
        houseId: state => state.houseId,
        startDate: state => state.startDate,
        endDate: state => state.endDate,
        totalMoney: state => state.totalMoney,
    },
    mutations: {
        updateLogin(state, payload) {
            state.isLogin = payload;
        },
        updateToken(state, payload) {
            state.token = payload;
        },
        updateUsername(state, payload) {
            state.username = payload;
        },
        updateHouseId(state, payload) {
            state.houseId = payload;
        },
        updateStartDate(state, payload) {
            state.startDate = payload;
        },
        updateEndDate(state, payload) {
            state.endDate = payload;
        },
        updateTotalMoney(state, payload) {
            state.totalMoney = payload;
        },
    },
    actions: {}
}
const store = new Vuex.Store(config);
export default store;